//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program.  If not, see http://www.gnu.org/licenses/.
//

#ifndef __WSN_WORLDUTILITYSTATS_H__
#define __WSN_WORLDUTILITYSTATS_H__

#include <omnetpp.h>
#include <BaseWorldUtility.h>

/**
 * @brief Collects global statistics (like channel usage) from the
 * global blackboard.
 *
 * @ingroup exampleIEEE802154Narrow
 */
class WSNWorldUtilityStats : public BaseWorldUtility,
						  public ImNotifiable
{
protected:
	/** @brief BBItem category for Packets*/
	int catPacket;

	/** @brief Stores the number of bits sent */
	double bitsSent;
	/** @brief Stores the number of bits received */
	double bitsReceived;

	cOutVector sent;
	cOutVector rcvd;

	cOutVector netUsage;
	cOutVector netTraffic;
	bool recordVectors;
	double vectorsInterval;
	double bitrate;
	cMessage* vectorsTimer;


protected:
    virtual void initialize(int stage);

public:
	virtual void receiveBBItem(int category, const BBItem *details, int scopeModuleId);
	void handleMessage(cMessage *msg);
	virtual void finish();
};

#endif
